package jumpingnotes.service;

import java.util.List;

import jumpingnotes.model.entity.Activity;
import jumpingnotes.model.entity.Audio;
import jumpingnotes.model.entity.Book;
import jumpingnotes.model.entity.BookComment;
import jumpingnotes.model.entity.BookVersion;
import jumpingnotes.model.entity.Chapter;
import jumpingnotes.model.entity.ChapterVersion;
import jumpingnotes.model.entity.Deploy;
import jumpingnotes.model.entity.ErrorReport;
import jumpingnotes.model.entity.Friend;
import jumpingnotes.model.entity.Group;
import jumpingnotes.model.entity.GroupTopic;
import jumpingnotes.model.entity.GroupTopicComment;
import jumpingnotes.model.entity.Member;
import jumpingnotes.model.entity.MemberExperience;
import jumpingnotes.model.entity.Message;
import jumpingnotes.model.entity.RecordAlbum;
import jumpingnotes.model.entity.RecordTask;
import jumpingnotes.model.entity.Sync;
import jumpingnotes.security.SessionManager;

public interface QueryService extends AccessService
{
	SessionManager getSessionManager();

	// -------------------- query --------------------

	List<Book> findBookByBookTag(String bookTag, int firstResult, int maxResults);

	List<Member> findMemberByGroupId(int groupId, int firstResult, int maxResults);

	Member findMemberByEmail(String email);

	List<Member> findMemberByFriendMemberId(int memberId, int firstResult, int maxResults);

	List<Group> findGroupByMemberId(int memberId);

	List<Chapter> findChapterByBookId(int bookId, int firstResult, int maxResults);

	List<Activity> findActivityByMemberId(int memberId, int firstResult, int maxResults);

	List<Book> findFavoriteBookByMemberId(int memberId);

	List<Activity> findActivityByGroupId(int groupId, int firstResult, int maxResults);

	List<GroupTopic> findGroupTopicByGroupId(int groupId, int firstResult, int maxResults);

	List<GroupTopic> findStickyTopicByGroupId(int groupId, int firstResult, int maxResults);

	List<RecordTask> findRecordTaskByRecordAlbumId(int recordAlbumId, int firstResult, int maxResults);

	List<BookComment> findBookCommentByBookId(int bookId, int firstResult, int maxResults);

	List<BookVersion> findValueByBookIdAndProperty(int bookId, String property);

	List<ChapterVersion> findValueByChapterIdAndProperty(int chapterId, String property);

	List<BookVersion> findBookVersionByBookId(int bookId, int firstResult, int maxResults);

	List<ChapterVersion> findChapterVersionByChapterId(int chapterId, int firstResult, int maxResults);

	List<RecordAlbum> findRecordAlbumByBookId(int bookId, int firstResult, int maxResults);

	List<RecordTask> findRecordTaskByChapterId(int chapterId, int firstResult, int maxResults);
	
	List<RecordAlbum> findRecordAlbumByMemberId(int memberId, int firstResult, int maxResults);
	
	boolean checkRecordTaskUnique(int chapterId, int recordAlbumId);
	
	boolean isFriend(int memberId1, int memberId2);
	
	boolean isMemberInGroup(int memberId, int groupId);
	
	List<MemberExperience> findMemberExperienceByMemberId(int memberId, int firstResult, int maxResults);
	
	List<Friend> findFriendFromByMemberId(int memberId, int firstResult, int maxResults);

	List<Friend> findFriendToByMemberId(int memberId, int firstResult, int maxResults);
	
	Audio findAudioByUuid(String uuid);
	
	Sync findSyncByUuid(String uuid);
	
	Deploy findDeployByUuid(String uuid);
	
	Chapter findChapterByUuid(String uuid);
	
	int countMemberByFavoriteBook(int bookId);

	List<Book> findBookLatest(int firstResult, int maxResults);

	List<Book> findBookPlayTop(int firstResult, int maxResults);

	List<Book> findBookRateTop(int firstResult, int maxResults);

	List<Book> findBookRecommend(int firstResult, int maxResults);
	
	List<Deploy> findDeployByAudioId(int audioId, int firstResult, int maxResults);
	
	List<Message> findMessageByMemberId(int memberId, int firstResult, int maxResults);
	
	List<Activity> findActivityPlaying(int firstResult, int maxResults);
	
	List<Activity> findActivityRecording(int firstResult, int maxResults);
	
	List<Activity> findActivityByFriendMemberId(int memberId, int firstResult, int maxResults);
	
	List<Activity> findActivityByAllGroupMemberId(int memberId, int firstResult, int maxResults);
	
	List<GroupTopicComment> findGroupTopicCommentByGroupTopicId(int groupTopicId, int firstResult, int maxResults);

	// -------------------- index --------------------

	void indexBook();

	List<Book> searchBook(String keyword, int firstResult, int maxResults);

	List<Book> searchBookByName(String keyword, int firstResult, int maxResults);

	List<Book> searchBookByAuthor(String keyword, int firstResult, int maxResults);
	
	void indexBookComment();

	List<BookComment> searchBookComment(String keyword, int firstResult, int maxResults);

	void indexChapter();

	List<Chapter> searchChapter(String keyword, int firstResult, int maxResults);

	void indexErrorReport();

	List<ErrorReport> searchErrorReport(String keyword, int firstResult, int maxResults);

	void indexGroup();

	List<Group> searchGroup(String keyword, int firstResult, int maxResults);

	void indexGroupTopic();

	List<GroupTopic> searchGroupTopic(String keyword, int firstResult, int maxResults);

	void indexGroupTopicComment();

	List<GroupTopicComment> searchGroupTopicComment(String keyword, int firstResult, int maxResults);

	void indexMember();

	List<Member> searchMember(String keyword, int firstResult, int maxResults);

	void indexMessage();

	List<Message> searchMessage(String keyword, int firstResult, int maxResults);
}
